﻿@model GsifWeb4.ViewModels.MatchReportViewModel

<script type="text/javascript">

    $(document).ready(function () {

        // Sätt ut kronan. Hämta diven som fått id = ManOfTheMatchPlayer och flytta kronan dit
        if ($("#ManOfTheMatchPlayer").length <= 0) {
            return;
        }

        var offsetTop = $("#ManOfTheMatchPlayer").attr("offsetTop");
        var offsetLeft = $("#ManOfTheMatchPlayer").attr("offsetLeft");

        if (navigator.appName == "Microsoft Internet Explorer") {
            krona.style.top = (div.offsetTop - 15) + "px";
            krona.style.left = (div.offsetLeft - 6) + "px";
        } else {
            krona.style.top = (offsetTop - 12) + "px";
            krona.style.left = (offsetLeft - 10) + "px";
        }
        krona.style.visibility = "visible";
    });

</script>


<div id="krona" style="position: absolute; width: 25px; height: 21px; z-index: 10; visibility: hidden;">
    <img src="/Images/SiteImages/krona.png" width="25" height="21" title="Matchens lirare!" alt="">
</div>

<div>
    <table width="70%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="40%"></td>
            <td width="8%"></td>
            <td width="4%"></td>
            <td width="8%"></td>
            <td width="40%"></td>
        </tr>
        <tr>
            <td align="center" valign="middle">
                @{
                    var homeTeam = Model.Match.HomeGame ? "GSIF" : Model.Match.Opponent;
                    var awayTeam = Model.Match.HomeGame ? Model.Match.Opponent : "GSIF";
                    string gsifImage = "<img src='/Images/SiteImages/logotype_43x45.jpg' width='43' height='45'/>";
                    string opponentImg = "<img src='/Images/SiteImages/fotboll_40x40.jpg' width='43' height='45'/>";
                    string homeTeamImg = Model.Match.HomeGame ? gsifImage : opponentImg;
                    string awayTeamImg = Model.Match.HomeGame ? opponentImg : gsifImage; 
                               
                }
                <h2>@homeTeam </h2>
                @(new HtmlString(homeTeamImg))
            </td>
            <td align="center" valign="middle">
                <br />
                <h1>@(Model.Match.HomeGame ? Model.Match.GoalsFullTimeGSIF : Model.Match.GoalsFullTimeOpponent)</h1>
                <h3>@(Model.Match.HomeGame ? Model.Match.GoalsHalfTimeGSIF : Model.Match.GoalsHalfTimeOpponent)</h3>
            </td>
            <td align="center" valign="middle">
                <br />
                <h1>-</h1>
            </td>
            <td align="center" valign="middle">
                <br />
                <h1>@(Model.Match.HomeGame ? Model.Match.GoalsFullTimeOpponent : Model.Match.GoalsFullTimeGSIF)</h1>
                <h3>@(Model.Match.HomeGame ? Model.Match.GoalsHalfTimeOpponent : Model.Match.GoalsHalfTimeGSIF)</h3>
            </td>
            <td align="center" valign="middle">
                <h2>@awayTeam</h2>
                @(new HtmlString(awayTeamImg))
            </td>
        </tr>
        <tr>
            <td colspan="5" align="center" valign="bottom">
                <b>@(Model.Match.WeekDay + " " + String.Format("{0:D}", Model.Match.Date) + " " + Model.Match.Time)
                    <br />
                    <br />
                    @(Model.Match.MatchType.SelectedValue + " " + (string.IsNullOrEmpty(Model.Match.Round) ? "" : " Omgång: " + Model.Match.Round))
                </b>
            </td>
        </tr>
        <tr>
            <td colspan="5">
                <hr width="100%">
                
            </td>
        </tr>
    </table>
</div>
<!-- End of header div -->

<div class="matchreportPitch">
    <table>
        <!-- Nedan kommer planen med alla spelarna -->
        <tr>
            <td colspan="3" align="center">

                <table width="480" height="302" border="0">
                    <tr>
                        <!-- Anfallare -->
                        @{Html.RenderPartial("_PlayersAtStartPosition", Model.MatchStatistics, new ViewDataDictionary { { "minPosition", 40 }, { "maxPosition", 50 } });}
                    </tr>
                    <tr>
                        <!-- Mittfältare -->
                        @{Html.RenderPartial("_PlayersAtStartPosition", Model.MatchStatistics, new ViewDataDictionary { { "minPosition", 30 }, { "maxPosition", 40 } });}
                    </tr>
                    <tr>
                        <!-- Försvarare -->
                        @{Html.RenderPartial("_PlayersAtStartPosition", Model.MatchStatistics, new ViewDataDictionary { { "minPosition", 20 }, { "maxPosition", 30 } });}
                    </tr>
                    <tr>
                        <!-- Målvakt -->
                        @{Html.RenderPartial("_PlayersAtStartPosition", Model.MatchStatistics, new ViewDataDictionary { { "minPosition", 10 }, { "maxPosition", 20 } });}
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>
<!-- Avbytare -->

<div class="alignLeft defaultMargin">
    @{Html.RenderPartial("_PlayersAtTheBench", Model.MatchStatistics, new ViewDataDictionary { { "minPosition", 50 }, { "maxPosition", 60 } });}
</div>

<div class="alignLeft defaultMargin">
    @GsifWeb4.ExtensionMethods.Label("Matchreferat:", new { @class = "fatLabel" })
    <br />

    @System.Web.HttpUtility.HtmlDecode(Model.Match.MatchReport)
</div>
